import axios from 'axios';
import {message} from 'antd'

const NO_ALERT_ERROR_CODE = new Set([]);

const RESPONSE_CODE = {

};

const request = axios.create({
  baseURL: '',
  timeout: 15000,
  headers: {
    'Content-Type': 'application/json',
  },
});
request.interceptors.response.use((value) =>{
  if (value?.data&&value?.data?.code===0 ) {
    return value?.data
  }
  message.destroy()
  message.error(value?.data?.msg||"服务器异常请稍后重试～")
  return {}
}, (error) => {
  message.destroy()
  message.error(error?.response?.data||"服务器异常请稍后重试～")
  return Promise.reject(error?.response?.data);
}
)
request.interceptors.request.use(
  function (config) {
    config.headers = config.headers || {};
    config.params = config.params || {};
    config.headers['Accept-Language'] = 'zh';
    config.headers.token = "";
    return config;
  },
  function (error) {
    return Promise.reject(error);
  },
);
export default request;
